home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Best of MacTutor - S…e Code for Volumes 1 to 5
/
The Best of MacTutor - Source Code for Volume 1-5 (Wayzata Technology)(6031)(1990).bin
/
Source Code
/
#19 (Apr 87)
/
help demo.c
/
atoi.c
next >
Wrap
Text File
|
1987-02-02
|
811b
|
38 lines
/***********************************************************************
* atoi.c - much smaller than unix & stdio libraries
*
* WN Rausch
* January 1987
**********************************************************************/
#include <MacTypes.h>
#include <pascal.h>
#include <strings.h>
#define isspace(c) (c == ' ' || c == '\t')
#define ZERO 48
/**********************************************************************/
atoi(string)
register char *string; /* must be NULL terminated */
{
register long answer = 0L;
Boolean negative = FALSE;
while (isspace(*string))
string++;
if (*string == '-')
negative = TRUE;
while (*string)
{
answer = (answer * 10) + (*string - ZERO);
string++;
}
if (negative)
answer = 0 - answer;
return (int)answer;
}